package com.tencreat.service.account.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.account.AccountSvipRecord;
import com.tencreat.mapper.account.AccountSvipRecordMapper;
import com.tencreat.service.account.IAccountSvipRecordService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户开通SVIP记录Service业务层处理
 *
 * @author tencreat
 * @date 2021-12-22
 */
@Service
public class AccountSvipRecordServiceImpl extends ServiceImpl<AccountSvipRecordMapper, AccountSvipRecord> implements IAccountSvipRecordService {


    /**
     * 查询用户开通SVIP记录
     *
     * @param id 用户开通SVIP记录ID
     * @return 用户开通SVIP记录
     */
    @Override
    public AccountSvipRecord selectAccountSvipRecordById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询用户开通SVIP记录列表
     *
     * @param accountSvipRecord 用户开通SVIP记录
     * @return 用户开通SVIP记录
     */
    @Override
    public List<AccountSvipRecord> selectAccountSvipRecordList(AccountSvipRecord accountSvipRecord) {
        return baseMapper.selectList(Wrappers.query(accountSvipRecord));
    }

    /**
     * 新增用户开通SVIP记录
     *
     * @param accountSvipRecord 用户开通SVIP记录
     * @return 结果
     */
    @Override
    public int insertAccountSvipRecord(AccountSvipRecord accountSvipRecord) {
        accountSvipRecord.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(accountSvipRecord);
    }

    /**
     * 修改用户开通SVIP记录
     *
     * @param accountSvipRecord 用户开通SVIP记录
     * @return 结果
     */
    @Override
    public int updateAccountSvipRecord(AccountSvipRecord accountSvipRecord) {
        accountSvipRecord.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(accountSvipRecord);
    }

    /**
     * 批量删除用户开通SVIP记录
     *
     * @param ids 需要删除的用户开通SVIP记录ID
     * @return 结果
     */
    @Override
    public int deleteAccountSvipRecordByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除用户开通SVIP记录信息
     *
     * @param id 用户开通SVIP记录ID
     * @return 结果
     */
    @Override
    public int deleteAccountSvipRecordById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
